
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  
<!-- Mirrored from werkzeug.palletsprojects.com/en/1.0.x/wrappers/ by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 15 Sep 2020 06:37:08 GMT -->
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Request / Response Objects &#8212; Werkzeug Documentation (1.0.x)</title>
    <link rel="stylesheet" href="../_static/werkzeug.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../../../assets.readthedocs.org/static/css/badge_only.css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script async="async" type="text/javascript" src="../../../../assets.readthedocs.org/static/javascript/readthedocs-doc-embed.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../genindex/index.html" />
    <link rel="search" title="Search" href="../search/index.html" />
    <link rel="next" title="URL Routing" href="../routing/index.html" />
    <link rel="prev" title="Debugging Applications" href="../debug/index.html" />
    <link rel="canonical" href="index.html">
  <script>DOCUMENTATION_OPTIONS.URL_ROOT = '../index.html';</script>
   
  
<!-- RTD Extra Head -->

<!-- 
Always link to the latest version, as canonical.
http://docs.readthedocs.org/en/latest/canonical.html
-->
<link rel="canonical" href="index.html" />

<link rel="stylesheet" href="../../../../assets.readthedocs.org/static/css/readthedocs-doc-embed.css" type="text/css" />

<script type="text/javascript" src="../_static/readthedocs-data.js"></script>

<!-- Add page-specific data, which must exist in the page js, not global -->
<script type="text/javascript">
READTHEDOCS_DATA['page'] = "wrappers"
READTHEDOCS_DATA['source_suffix'] = ".rst"
</script>

<script type="text/javascript" src="../../../../assets.readthedocs.org/static/javascript/readthedocs-analytics.js" async="async"></script>

<!-- end RTD <extrahead> -->
</head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex/index.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex/index.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../routing/index.html" title="URL Routing"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../debug/index.html" title="Debugging Applications"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">Werkzeug Documentation (1.0.x)</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-werkzeug.wrappers">
<span id="request-response-objects"></span><span id="wrappers"></span><h1>Request / Response Objects<a class="headerlink" href="#module-werkzeug.wrappers" title="Permalink to this headline">¶</a></h1>
<p>The request and response objects wrap the WSGI environment or the return
value from a WSGI application so that it is another WSGI application
(wraps a whole application).</p>
<div class="section" id="how-they-work">
<h2>How they Work<a class="headerlink" href="#how-they-work" title="Permalink to this headline">¶</a></h2>
<p>Your WSGI application is always passed two arguments.  The WSGI “environment”
and the WSGI <cite>start_response</cite> function that is used to start the response
phase.  The <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">Request</span></code></a> class wraps the <cite>environ</cite> for easier access to
request variables (form data, request headers etc.).</p>
<p>The <a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal notranslate"><span class="pre">Response</span></code></a> on the other hand is a standard WSGI application that
you can create.  The simple hello world in Werkzeug looks like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="k">import</span> <span class="n">Response</span>
<span class="n">application</span> <span class="o">=</span> <span class="n">Response</span><span class="p">(</span><span class="s1">&#39;Hello World!&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>To make it more useful you can replace it with a function and do some
processing:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="k">import</span> <span class="n">Request</span><span class="p">,</span> <span class="n">Response</span>

<span class="k">def</span> <span class="nf">application</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">):</span>
    <span class="n">request</span> <span class="o">=</span> <span class="n">Request</span><span class="p">(</span><span class="n">environ</span><span class="p">)</span>
    <span class="n">response</span> <span class="o">=</span> <span class="n">Response</span><span class="p">(</span><span class="s2">&quot;Hello </span><span class="si">%s</span><span class="s2">!&quot;</span> <span class="o">%</span> <span class="n">request</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;World!&#39;</span><span class="p">))</span>
    <span class="k">return</span> <span class="n">response</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">)</span>
</pre></div>
</div>
<p>Because this is a very common task the <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">Request</span></code></a> object provides
a helper for that.  The above code can be rewritten like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="k">import</span> <span class="n">Request</span><span class="p">,</span> <span class="n">Response</span>

<span class="nd">@Request</span><span class="o">.</span><span class="n">application</span>
<span class="k">def</span> <span class="nf">application</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">Response</span><span class="p">(</span><span class="s2">&quot;Hello </span><span class="si">%s</span><span class="s2">!&quot;</span> <span class="o">%</span> <span class="n">request</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;World!&#39;</span><span class="p">))</span>
</pre></div>
</div>
<p>The <cite>application</cite> is still a valid WSGI application that accepts the
environment and <cite>start_response</cite> callable.</p>
</div>
<div class="section" id="mutability-and-reusability-of-wrappers">
<h2>Mutability and Reusability of Wrappers<a class="headerlink" href="#mutability-and-reusability-of-wrappers" title="Permalink to this headline">¶</a></h2>
<p>The implementation of the Werkzeug request and response objects are trying
to guard you from common pitfalls by disallowing certain things as much as
possible.  This serves two purposes: high performance and avoiding of
pitfalls.</p>
<p>For the request object the following rules apply:</p>
<ol class="arabic simple">
<li>The request object is immutable.  Modifications are not supported by
default, you may however replace the immutable attributes with mutable
attributes if you need to modify it.</li>
<li>The request object may be shared in the same thread, but is not thread
safe itself.  If you need to access it from multiple threads, use
locks around calls.</li>
<li>It’s not possible to pickle the request object.</li>
</ol>
<p>For the response object the following rules apply:</p>
<ol class="arabic simple">
<li>The response object is mutable</li>
<li>The response object can be pickled or copied after <cite>freeze()</cite> was
called.</li>
<li>Since Werkzeug 0.6 it’s safe to use the same response object for
multiple WSGI responses.</li>
<li>It’s possible to create copies using <cite>copy.deepcopy</cite>.</li>
</ol>
</div>
<div class="section" id="base-wrappers">
<h2>Base Wrappers<a class="headerlink" href="#base-wrappers" title="Permalink to this headline">¶</a></h2>
<p>These objects implement a common set of operations.  They are missing fancy
addon functionality like user agent parsing or etag handling.  These features
are available by mixing in various mixin classes or using <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">Request</span></code></a> and
<a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal notranslate"><span class="pre">Response</span></code></a>.</p>
<dl class="class">
<dt id="werkzeug.wrappers.BaseRequest">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">BaseRequest</code><span class="sig-paren">(</span><em>environ</em>, <em>populate_request=True</em>, <em>shallow=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest" title="Permalink to this definition">¶</a></dt>
<dd><p>Very basic request object.  This does not implement advanced stuff like
entity tag parsing or cache controls.  The request object is created with
the WSGI environment as first argument and will add itself to the WSGI
environment as <code class="docutils literal notranslate"><span class="pre">'werkzeug.request'</span></code> unless it’s created with
<cite>populate_request</cite> set to False.</p>
<p>There are a couple of mixins available that add additional functionality
to the request object, there is also a class called <cite>Request</cite> which
subclasses <cite>BaseRequest</cite> and all the important mixins.</p>
<p>It’s a good idea to create a custom subclass of the <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseRequest</span></code></a>
and add missing functionality either via mixins or direct implementation.
Here an example for such subclasses:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="k">import</span> <span class="n">BaseRequest</span><span class="p">,</span> <span class="n">ETagRequestMixin</span>

<span class="k">class</span> <span class="nc">Request</span><span class="p">(</span><span class="n">BaseRequest</span><span class="p">,</span> <span class="n">ETagRequestMixin</span><span class="p">):</span>
    <span class="k">pass</span>
</pre></div>
</div>
<p>Request objects are <strong>read only</strong>.  As of 0.5 modifications are not
allowed in any place.  Unlike the lower level parsing functions the
request object will use immutable objects everywhere possible.</p>
<p>Per default the request object will assume all the text data is <cite>utf-8</cite>
encoded.  Please refer to <a class="reference internal" href="../unicode/index.html"><span class="doc">the unicode chapter</span></a> for more
details about customizing the behavior.</p>
<p>Per default the request object will be added to the WSGI
environment as <cite>werkzeug.request</cite> to support the debugging system.
If you don’t want that, set <cite>populate_request</cite> to <cite>False</cite>.</p>
<p>If <cite>shallow</cite> is <cite>True</cite> the environment is initialized as shallow
object around the environ.  Every operation that would modify the
environ in any way (such as consuming form data) raises an exception
unless the <cite>shallow</cite> attribute is explicitly set to <cite>False</cite>.  This
is useful for middlewares where you don’t want to consume the form
data by accident.  A shallow request is not populated to the WSGI
environment.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>read-only mode was enforced by using immutables classes for all
data.</p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.environ">
<code class="descname">environ</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.environ" title="Permalink to this definition">¶</a></dt>
<dd><p>The WSGI environment that the request object uses for data retrival.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.shallow">
<code class="descname">shallow</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.shallow" title="Permalink to this definition">¶</a></dt>
<dd><p><cite>True</cite> if this request object is shallow (does not modify <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.environ" title="werkzeug.wrappers.BaseRequest.environ"><code class="xref py py-attr docutils literal notranslate"><span class="pre">environ</span></code></a>),
<cite>False</cite> otherwise.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseRequest._get_file_stream">
<code class="descname">_get_file_stream</code><span class="sig-paren">(</span><em>total_content_length</em>, <em>content_type</em>, <em>filename=None</em>, <em>content_length=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest._get_file_stream" title="Permalink to this definition">¶</a></dt>
<dd><p>Called to get a stream for the file upload.</p>
<p>This must provide a file-like class with <cite>read()</cite>, <cite>readline()</cite>
and <cite>seek()</cite> methods that is both writeable and readable.</p>
<p>The default implementation returns a temporary file if the total
content length is higher than 500KB.  Because many browsers do not
provide a content length for the files only the total content
length matters.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>total_content_length</strong> – the total content length of all the
data in the request combined.  This value
is guaranteed to be there.</li>
<li><strong>content_type</strong> – the mimetype of the uploaded file.</li>
<li><strong>filename</strong> – the filename of the uploaded file.  May be <cite>None</cite>.</li>
<li><strong>content_length</strong> – the length of this file.  This value is usually
not provided because webbrowsers do not provide
this value.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.access_route">
<code class="descname">access_route</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.access_route" title="Permalink to this definition">¶</a></dt>
<dd><p>If a forwarded header exists this is a list of all ip addresses
from the client ip to the last proxy server.</p>
</dd></dl>

<dl class="classmethod">
<dt id="werkzeug.wrappers.BaseRequest.application">
<em class="property">classmethod </em><code class="descname">application</code><span class="sig-paren">(</span><em>f</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.application" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorate a function as responder that accepts the request as
the last argument.  This works like the <code class="xref py py-func docutils literal notranslate"><span class="pre">responder()</span></code>
decorator but the function is passed the request object as the
last argument and the request object will be closed
automatically:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@Request</span><span class="o">.</span><span class="n">application</span>
<span class="k">def</span> <span class="nf">my_wsgi_app</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">Response</span><span class="p">(</span><span class="s1">&#39;Hello World!&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>As of Werkzeug 0.14 HTTP exceptions are automatically caught and
converted to responses instead of failing.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>f</strong> – the WSGI callable to decorate</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a new WSGI callable</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.args">
<code class="descname">args</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.args" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed URL parameters (the part in the URL after the question
mark).</p>
<p>By default an
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.ImmutableMultiDict" title="werkzeug.datastructures.ImmutableMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">ImmutableMultiDict</span></code></a>
is returned from this function.  This can be changed by setting
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.parameter_storage_class" title="werkzeug.wrappers.BaseRequest.parameter_storage_class"><code class="xref py py-attr docutils literal notranslate"><span class="pre">parameter_storage_class</span></code></a> to a different type.  This might
be necessary if the order of the form data is important.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.base_url">
<code class="descname">base_url</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.base_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.url" title="werkzeug.wrappers.BaseRequest.url"><code class="xref py py-attr docutils literal notranslate"><span class="pre">url</span></code></a> but without the querystring
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal notranslate"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.charset">
<code class="descname">charset</code><em class="property"> = 'utf-8'</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.charset" title="Permalink to this definition">¶</a></dt>
<dd><p>the charset for the request, defaults to utf-8</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseRequest.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Closes associated resources of this request object.  This
closes all file handles explicitly.  You can also use the request
object in a with statement which will automatically close it.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.cookies">
<code class="descname">cookies</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.cookies" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a> with the contents of all cookies transmitted with
the request.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.data">
<code class="descname">data</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.data" title="Permalink to this definition">¶</a></dt>
<dd><p>Contains the incoming request data as string in case it came with
a mimetype Werkzeug does not handle.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.dict_storage_class">
<code class="descname">dict_storage_class</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.dict_storage_class" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.ImmutableMultiDict" title="werkzeug.datastructures.ImmutableMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">werkzeug.datastructures.ImmutableMultiDict</span></code></a></p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.disable_data_descriptor">
<code class="descname">disable_data_descriptor</code><em class="property"> = False</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.disable_data_descriptor" title="Permalink to this definition">¶</a></dt>
<dd><p>Indicates whether the data descriptor should be allowed to read and
buffer up the input stream.  By default it’s enabled.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.encoding_errors">
<code class="descname">encoding_errors</code><em class="property"> = 'replace'</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.encoding_errors" title="Permalink to this definition">¶</a></dt>
<dd><p>the error handling procedure for errors, defaults to ‘replace’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.files">
<code class="descname">files</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.files" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> object containing
all uploaded files.  Each key in <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> is the name from the
<code class="docutils literal notranslate"><span class="pre">&lt;input</span> <span class="pre">type=&quot;file&quot;</span> <span class="pre">name=&quot;&quot;&gt;</span></code>.  Each value in <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> is a
Werkzeug <a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.FileStorage" title="werkzeug.datastructures.FileStorage"><code class="xref py py-class docutils literal notranslate"><span class="pre">FileStorage</span></code></a> object.</p>
<p>It basically behaves like a standard file object you know from Python,
with the difference that it also has a
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.FileStorage.save" title="werkzeug.datastructures.FileStorage.save"><code class="xref py py-meth docutils literal notranslate"><span class="pre">save()</span></code></a> function that can
store the file on the filesystem.</p>
<p>Note that <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> will only contain data if the request method was
POST, PUT or PATCH and the <code class="docutils literal notranslate"><span class="pre">&lt;form&gt;</span></code> that posted to the request had
<code class="docutils literal notranslate"><span class="pre">enctype=&quot;multipart/form-data&quot;</span></code>.  It will be empty otherwise.</p>
<p>See the <a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> /
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.FileStorage" title="werkzeug.datastructures.FileStorage"><code class="xref py py-class docutils literal notranslate"><span class="pre">FileStorage</span></code></a> documentation for
more details about the used data structure.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.form">
<code class="descname">form</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.form" title="Permalink to this definition">¶</a></dt>
<dd><p>The form parameters.  By default an
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.ImmutableMultiDict" title="werkzeug.datastructures.ImmutableMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">ImmutableMultiDict</span></code></a>
is returned from this function.  This can be changed by setting
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.parameter_storage_class" title="werkzeug.wrappers.BaseRequest.parameter_storage_class"><code class="xref py py-attr docutils literal notranslate"><span class="pre">parameter_storage_class</span></code></a> to a different type.  This might
be necessary if the order of the form data is important.</p>
<p>Please keep in mind that file uploads will not end up here, but instead
in the <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> attribute.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.9: </span>Previous to Werkzeug 0.9 this would only contain form data for POST
and PUT requests.</p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.form_data_parser_class">
<code class="descname">form_data_parser_class</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.form_data_parser_class" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <a class="reference internal" href="../http/index.html#werkzeug.formparser.FormDataParser" title="werkzeug.formparser.FormDataParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">werkzeug.formparser.FormDataParser</span></code></a></p>
</dd></dl>

<dl class="classmethod">
<dt id="werkzeug.wrappers.BaseRequest.from_values">
<em class="property">classmethod </em><code class="descname">from_values</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.from_values" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new request object based on the values provided.  If
environ is given missing values are filled from there.  This method is
useful for small scripts when you need to simulate a request from an URL.
Do not use this method for unittesting, there is a full featured client
object (<code class="xref py py-class docutils literal notranslate"><span class="pre">Client</span></code>) that allows to create multipart requests,
support for cookies etc.</p>
<p>This accepts the same options as the
<a class="reference internal" href="../test/index.html#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>This method now accepts the same arguments as
<a class="reference internal" href="../test/index.html#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a>.  Because of this the
<cite>environ</cite> parameter is now called <cite>environ_overrides</cite>.</p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">request object</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.full_path">
<code class="descname">full_path</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.full_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Requested path as unicode, including the query string.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseRequest.get_data">
<code class="descname">get_data</code><span class="sig-paren">(</span><em>cache=True</em>, <em>as_text=False</em>, <em>parse_form_data=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.get_data" title="Permalink to this definition">¶</a></dt>
<dd><p>This reads the buffered incoming data from the client into one
bytestring.  By default this is cached but that behavior can be
changed by setting <cite>cache</cite> to <cite>False</cite>.</p>
<p>Usually it’s a bad idea to call this method without checking the
content length first as a client could send dozens of megabytes or more
to cause memory problems on the server.</p>
<p>Note that if the form data was already parsed this method will not
return anything as form data parsing does not cache the data like
this method does.  To implicitly invoke form data parsing function
set <cite>parse_form_data</cite> to <cite>True</cite>.  When this is done the return value
of this method will be an empty string if the form parser handles
the data.  This generally is not necessary as if the whole data is
cached (which is the default) the form parser will used the cached
data to parse the form data.  Please be generally aware of checking
the content length first in any case before calling this method
to avoid exhausting server memory.</p>
<p>If <cite>as_text</cite> is set to <cite>True</cite> the return value will be a decoded
unicode string.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.headers">
<code class="descname">headers</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>The headers from the WSGI environ as immutable
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.EnvironHeaders" title="werkzeug.datastructures.EnvironHeaders"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironHeaders</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.host">
<code class="descname">host</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.host" title="Permalink to this definition">¶</a></dt>
<dd><p>Just the host including the port if available.
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal notranslate"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.host_url">
<code class="descname">host_url</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.host_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Just the host with scheme as IRI.
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal notranslate"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_multiprocess">
<code class="descname">is_multiprocess</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_multiprocess" title="Permalink to this definition">¶</a></dt>
<dd><p>boolean that is <cite>True</cite> if the application is served by a
WSGI server that spawns multiple processes.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_multithread">
<code class="descname">is_multithread</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_multithread" title="Permalink to this definition">¶</a></dt>
<dd><p>boolean that is <cite>True</cite> if the application is served by a
multithreaded WSGI server.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_run_once">
<code class="descname">is_run_once</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_run_once" title="Permalink to this definition">¶</a></dt>
<dd><p>boolean that is <cite>True</cite> if the application will be
executed only once in a process lifetime.  This is the case for
CGI for example, but it’s not guaranteed that the execution only
happens one time.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.is_secure">
<code class="descname">is_secure</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.is_secure" title="Permalink to this definition">¶</a></dt>
<dd><p><cite>True</cite> if the request is secure.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.list_storage_class">
<code class="descname">list_storage_class</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.list_storage_class" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.ImmutableList" title="werkzeug.datastructures.ImmutableList"><code class="xref py py-class docutils literal notranslate"><span class="pre">werkzeug.datastructures.ImmutableList</span></code></a></p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseRequest.make_form_data_parser">
<code class="descname">make_form_data_parser</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.make_form_data_parser" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates the form data parser. Instantiates the
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.form_data_parser_class" title="werkzeug.wrappers.BaseRequest.form_data_parser_class"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form_data_parser_class</span></code></a> with some parameters.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.max_content_length">
<code class="descname">max_content_length</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.max_content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>the maximum content length.  This is forwarded to the form data
parsing function (<code class="xref py py-func docutils literal notranslate"><span class="pre">parse_form_data()</span></code>).  When set and the
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.form" title="werkzeug.wrappers.BaseRequest.form"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form</span></code></a> or <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> attribute is accessed and the
parsing fails because more than the specified value is transmitted
a <a class="reference internal" href="../exceptions/index.html#werkzeug.exceptions.RequestEntityTooLarge" title="werkzeug.exceptions.RequestEntityTooLarge"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RequestEntityTooLarge</span></code></a> exception is raised.</p>
<p>Have a look at <a class="reference internal" href="../request_data/index.html#dealing-with-request-data"><span class="std std-ref">Dealing with Request Data</span></a> for more details.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.max_form_memory_size">
<code class="descname">max_form_memory_size</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.max_form_memory_size" title="Permalink to this definition">¶</a></dt>
<dd><p>the maximum form field size.  This is forwarded to the form data
parsing function (<code class="xref py py-func docutils literal notranslate"><span class="pre">parse_form_data()</span></code>).  When set and the
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.form" title="werkzeug.wrappers.BaseRequest.form"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form</span></code></a> or <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.files" title="werkzeug.wrappers.BaseRequest.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> attribute is accessed and the
data in memory for post data is longer than the specified value a
<a class="reference internal" href="../exceptions/index.html#werkzeug.exceptions.RequestEntityTooLarge" title="werkzeug.exceptions.RequestEntityTooLarge"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RequestEntityTooLarge</span></code></a> exception is raised.</p>
<p>Have a look at <a class="reference internal" href="../request_data/index.html#dealing-with-request-data"><span class="std std-ref">Dealing with Request Data</span></a> for more details.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.method">
<code class="descname">method</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.method" title="Permalink to this definition">¶</a></dt>
<dd><p>The request method. (For example <code class="docutils literal notranslate"><span class="pre">'GET'</span></code> or <code class="docutils literal notranslate"><span class="pre">'POST'</span></code>).</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.parameter_storage_class">
<code class="descname">parameter_storage_class</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.parameter_storage_class" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.ImmutableMultiDict" title="werkzeug.datastructures.ImmutableMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">werkzeug.datastructures.ImmutableMultiDict</span></code></a></p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.path">
<code class="descname">path</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.path" title="Permalink to this definition">¶</a></dt>
<dd><p>Requested path as unicode.  This works a bit like the regular path
info in the WSGI environment but will always include a leading slash,
even if the URL root is accessed.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.query_string">
<code class="descname">query_string</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.query_string" title="Permalink to this definition">¶</a></dt>
<dd><p>The URL parameters as raw bytestring.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.remote_addr">
<code class="descname">remote_addr</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.remote_addr" title="Permalink to this definition">¶</a></dt>
<dd><p>The remote address of the client.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.remote_user">
<code class="descname">remote_user</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.remote_user" title="Permalink to this definition">¶</a></dt>
<dd><p>If the server supports user authentication, and the
script is protected, this attribute contains the username the
user has authenticated as.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.scheme">
<code class="descname">scheme</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.scheme" title="Permalink to this definition">¶</a></dt>
<dd><p>URL scheme (http or https).</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.script_root">
<code class="descname">script_root</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.script_root" title="Permalink to this definition">¶</a></dt>
<dd><p>The root path of the script without the trailing slash.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.stream">
<code class="descname">stream</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.stream" title="Permalink to this definition">¶</a></dt>
<dd><p>If the incoming form data was not encoded with a known mimetype
the data is stored unmodified in this stream for consumption.  Most
of the time it is a better idea to use <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.data" title="werkzeug.wrappers.BaseRequest.data"><code class="xref py py-attr docutils literal notranslate"><span class="pre">data</span></code></a> which will give
you that data as a string.  The stream only returns the data once.</p>
<p>Unlike <code class="xref py py-attr docutils literal notranslate"><span class="pre">input_stream</span></code> this stream is properly guarded that you
can’t accidentally read past the length of the input.  Werkzeug will
internally always refer to this stream to read data which makes it
possible to wrap this object with a stream that does filtering.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.9: </span>This stream is now always available but might be consumed by the
form parser later on.  Previously the stream was only set if no
parsing happened.</p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.trusted_hosts">
<code class="descname">trusted_hosts</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="Permalink to this definition">¶</a></dt>
<dd><p>Optionally a list of hosts that is trusted by this request.  By default
all hosts are trusted which means that whatever the client sends the
host is will be accepted.</p>
<p>Because <cite>Host</cite> and <cite>X-Forwarded-Host</cite> headers can be set to any value by
a malicious client, it is recommended to either set this property or
implement similar validation in the proxy (if application is being run
behind one).</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.url">
<code class="descname">url</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.url" title="Permalink to this definition">¶</a></dt>
<dd><p>The reconstructed current URL as IRI.
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal notranslate"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.url_charset">
<code class="descname">url_charset</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.url_charset" title="Permalink to this definition">¶</a></dt>
<dd><p>The charset that is assumed for URLs.  Defaults to the value
of <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.charset" title="werkzeug.wrappers.BaseRequest.charset"><code class="xref py py-attr docutils literal notranslate"><span class="pre">charset</span></code></a>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.url_root">
<code class="descname">url_root</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.url_root" title="Permalink to this definition">¶</a></dt>
<dd><p>The full URL root (with hostname), this is the application
root as IRI.
See also: <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.trusted_hosts" title="werkzeug.wrappers.BaseRequest.trusted_hosts"><code class="xref py py-attr docutils literal notranslate"><span class="pre">trusted_hosts</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.values">
<code class="descname">values</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.values" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.CombinedMultiDict" title="werkzeug.datastructures.CombinedMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">werkzeug.datastructures.CombinedMultiDict</span></code></a> that combines
<a class="reference internal" href="#werkzeug.wrappers.BaseRequest.args" title="werkzeug.wrappers.BaseRequest.args"><code class="xref py py-attr docutils literal notranslate"><span class="pre">args</span></code></a> and <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.form" title="werkzeug.wrappers.BaseRequest.form"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseRequest.want_form_data_parsed">
<code class="descname">want_form_data_parsed</code><a class="headerlink" href="#werkzeug.wrappers.BaseRequest.want_form_data_parsed" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if the request method carries content.  As of
Werkzeug 0.9 this will be the case if a content type is transmitted.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</details></dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.wrappers.BaseResponse">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">BaseResponse</code><span class="sig-paren">(</span><em>response=None</em>, <em>status=None</em>, <em>headers=None</em>, <em>mimetype=None</em>, <em>content_type=None</em>, <em>direct_passthrough=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse" title="Permalink to this definition">¶</a></dt>
<dd><p>Base response class.  The most important fact about a response object
is that it’s a regular WSGI application.  It’s initialized with a couple
of response parameters (headers, body, status code etc.) and will start a
valid WSGI response when called with the environ and start response
callable.</p>
<p>Because it’s a WSGI application itself processing usually ends before the
actual response is sent to the server.  This helps debugging systems
because they can catch all the exceptions before responses are started.</p>
<p>Here a small example WSGI application that takes advantage of the
response objects:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="k">import</span> <span class="n">BaseResponse</span> <span class="k">as</span> <span class="n">Response</span>

<span class="k">def</span> <span class="nf">index</span><span class="p">():</span>
    <span class="k">return</span> <span class="n">Response</span><span class="p">(</span><span class="s1">&#39;Index page&#39;</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">application</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">):</span>
    <span class="n">path</span> <span class="o">=</span> <span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;PATH_INFO&#39;</span><span class="p">)</span> <span class="ow">or</span> <span class="s1">&#39;/&#39;</span>
    <span class="k">if</span> <span class="n">path</span> <span class="o">==</span> <span class="s1">&#39;/&#39;</span><span class="p">:</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">index</span><span class="p">()</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">Response</span><span class="p">(</span><span class="s1">&#39;Not Found&#39;</span><span class="p">,</span> <span class="n">status</span><span class="o">=</span><span class="mi">404</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">response</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">)</span>
</pre></div>
</div>
<p>Like <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseRequest</span></code></a> which object is lacking a lot of functionality
implemented in mixins.  This gives you a better control about the actual
API of your response objects, so you can create subclasses and add custom
functionality.  A full featured response object is available as
<a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal notranslate"><span class="pre">Response</span></code></a> which implements a couple of useful mixins.</p>
<p>To enforce a new type of already existing responses you can use the
<a class="reference internal" href="#werkzeug.wrappers.BaseResponse.force_type" title="werkzeug.wrappers.BaseResponse.force_type"><code class="xref py py-meth docutils literal notranslate"><span class="pre">force_type()</span></code></a> method.  This is useful if you’re working with different
subclasses of response objects and you want to post process them with a
known interface.</p>
<p>Per default the response object will assume all the text data is <cite>utf-8</cite>
encoded.  Please refer to <a class="reference internal" href="../unicode/index.html"><span class="doc">the unicode chapter</span></a> for more
details about customizing the behavior.</p>
<p>Response can be any kind of iterable or string.  If it’s a string it’s
considered being an iterable with one item which is the string passed.
Headers can be a list of tuples or a
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a> object.</p>
<p>Special note for <cite>mimetype</cite> and <cite>content_type</cite>:  For most mime types
<cite>mimetype</cite> and <cite>content_type</cite> work the same, the difference affects
only ‘text’ mimetypes.  If the mimetype passed with <cite>mimetype</cite> is a
mimetype starting with <cite>text/</cite>, the charset parameter of the response
object is appended to it.  In contrast the <cite>content_type</cite> parameter is
always added as header unmodified.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>the <cite>direct_passthrough</cite> parameter was added.</p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>response</strong> – a string or response iterable.</li>
<li><strong>status</strong> – a string with a status or an integer with the status code.</li>
<li><strong>headers</strong> – a list of headers or a
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a> object.</li>
<li><strong>mimetype</strong> – the mimetype for the response.  See notice above.</li>
<li><strong>content_type</strong> – the content type for the response.  See notice above.</li>
<li><strong>direct_passthrough</strong> – if set to <cite>True</cite> <a class="reference internal" href="#werkzeug.wrappers.BaseResponse.iter_encoded" title="werkzeug.wrappers.BaseResponse.iter_encoded"><code class="xref py py-meth docutils literal notranslate"><span class="pre">iter_encoded()</span></code></a> is not
called before iteration which makes it
possible to pass special iterators through
unchanged (see <code class="xref py py-func docutils literal notranslate"><span class="pre">wrap_file()</span></code> for more
details.)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.response">
<code class="descname">response</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.response" title="Permalink to this definition">¶</a></dt>
<dd><p>The application iterator.  If constructed from a string this will be a
list, otherwise the object provided as application iterator.  (The first
argument passed to <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseResponse</span></code></a>)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.headers">
<code class="descname">headers</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code> object representing the response headers.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.status_code">
<code class="descname">status_code</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.status_code" title="Permalink to this definition">¶</a></dt>
<dd><p>The response status as integer.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.direct_passthrough">
<code class="descname">direct_passthrough</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.direct_passthrough" title="Permalink to this definition">¶</a></dt>
<dd><p>If <code class="docutils literal notranslate"><span class="pre">direct_passthrough=True</span></code> was passed to the response object or if
this attribute was set to <cite>True</cite> before using the response object as
WSGI application, the wrapped iterator is returned unchanged.  This
makes it possible to pass a special <cite>wsgi.file_wrapper</cite> to the response
object.  See <code class="xref py py-func docutils literal notranslate"><span class="pre">wrap_file()</span></code> for more details.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.__call__">
<code class="descname">__call__</code><span class="sig-paren">(</span><em>environ</em>, <em>start_response</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.__call__" title="Permalink to this definition">¶</a></dt>
<dd><p>Process this response as WSGI application.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>environ</strong> – the WSGI environment.</li>
<li><strong>start_response</strong> – the response callable provided by the WSGI
server.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">an application iterator</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse._ensure_sequence">
<code class="descname">_ensure_sequence</code><span class="sig-paren">(</span><em>mutable=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse._ensure_sequence" title="Permalink to this definition">¶</a></dt>
<dd><p>This method can be called by methods that need a sequence.  If
<cite>mutable</cite> is true, it will also ensure that the response sequence
is a standard Python list.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.autocorrect_location_header">
<code class="descname">autocorrect_location_header</code><em class="property"> = True</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.autocorrect_location_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Should this response object correct the location header to be RFC
conformant?  This is true by default.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.automatically_set_content_length">
<code class="descname">automatically_set_content_length</code><em class="property"> = True</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.automatically_set_content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>Should this response object automatically set the content-length
header if possible?  This is true by default.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.calculate_content_length">
<code class="descname">calculate_content_length</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.calculate_content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the content length if available or <cite>None</cite> otherwise.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.call_on_close">
<code class="descname">call_on_close</code><span class="sig-paren">(</span><em>func</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.call_on_close" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a function to the internal list of functions that should
be called as part of closing down the response.  Since 0.7 this
function also returns the function that was passed so that this
can be used as a decorator.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.charset">
<code class="descname">charset</code><em class="property"> = 'utf-8'</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.charset" title="Permalink to this definition">¶</a></dt>
<dd><p>the charset of the response.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the wrapped response if possible.  You can also use the object
in a with statement which will automatically close it.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9: </span>Can now be used in a with statement.</p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.data">
<code class="descname">data</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.data" title="Permalink to this definition">¶</a></dt>
<dd><p>A descriptor that calls <a class="reference internal" href="#werkzeug.wrappers.BaseResponse.get_data" title="werkzeug.wrappers.BaseResponse.get_data"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_data()</span></code></a> and <a class="reference internal" href="#werkzeug.wrappers.BaseResponse.set_data" title="werkzeug.wrappers.BaseResponse.set_data"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_data()</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.default_mimetype">
<code class="descname">default_mimetype</code><em class="property"> = 'text/plain'</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.default_mimetype" title="Permalink to this definition">¶</a></dt>
<dd><p>the default mimetype if none is provided.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.default_status">
<code class="descname">default_status</code><em class="property"> = 200</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.default_status" title="Permalink to this definition">¶</a></dt>
<dd><p>the default status if none is provided.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.delete_cookie">
<code class="descname">delete_cookie</code><span class="sig-paren">(</span><em>key</em>, <em>path='/'</em>, <em>domain=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.delete_cookie" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete a cookie.  Fails silently if key doesn’t exist.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – the key (name) of the cookie to be deleted.</li>
<li><strong>path</strong> – if the cookie that should be deleted was limited to a
path, the path has to be defined here.</li>
<li><strong>domain</strong> – if the cookie that should be deleted was limited to a
domain, that domain has to be defined here.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="classmethod">
<dt id="werkzeug.wrappers.BaseResponse.force_type">
<em class="property">classmethod </em><code class="descname">force_type</code><span class="sig-paren">(</span><em>response</em>, <em>environ=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.force_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Enforce that the WSGI response is a response object of the current
type.  Werkzeug will use the <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseResponse</span></code></a> internally in many
situations like the exceptions.  If you call <code class="xref py py-meth docutils literal notranslate"><span class="pre">get_response()</span></code> on an
exception you will get back a regular <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseResponse</span></code></a> object, even
if you are using a custom subclass.</p>
<p>This method can enforce a given response type, and it will also
convert arbitrary WSGI callables into response objects if an environ
is provided:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># convert a Werkzeug response object into an instance of the</span>
<span class="c1"># MyResponseClass subclass.</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">MyResponseClass</span><span class="o">.</span><span class="n">force_type</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>

<span class="c1"># convert any WSGI application into a response object</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">MyResponseClass</span><span class="o">.</span><span class="n">force_type</span><span class="p">(</span><span class="n">response</span><span class="p">,</span> <span class="n">environ</span><span class="p">)</span>
</pre></div>
</div>
<p>This is especially useful if you want to post-process responses in
the main dispatcher and use functionality provided by your subclass.</p>
<p>Keep in mind that this will modify response objects in place if
possible!</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>response</strong> – a response object or wsgi application.</li>
<li><strong>environ</strong> – a WSGI environment object.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a response object.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.freeze">
<code class="descname">freeze</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.freeze" title="Permalink to this definition">¶</a></dt>
<dd><p>Call this method if you want to make your response object ready for
being pickled.  This buffers the generator if there is one.  It will
also set the <cite>Content-Length</cite> header to the length of the body.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.6: </span>The <cite>Content-Length</cite> header is now set.</p>
</div>
</details></dd></dl>

<dl class="classmethod">
<dt id="werkzeug.wrappers.BaseResponse.from_app">
<em class="property">classmethod </em><code class="descname">from_app</code><span class="sig-paren">(</span><em>app</em>, <em>environ</em>, <em>buffered=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.from_app" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new response object from an application output.  This
works best if you pass it an application that returns a generator all
the time.  Sometimes applications may use the <cite>write()</cite> callable
returned by the <cite>start_response</cite> function.  This tries to resolve such
edge cases automatically.  But if you don’t get the expected output
you should set <cite>buffered</cite> to <cite>True</cite> which enforces buffering.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>app</strong> – the WSGI application to execute.</li>
<li><strong>environ</strong> – the WSGI environment to execute against.</li>
<li><strong>buffered</strong> – set to <cite>True</cite> to enforce buffering.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a response object.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.get_app_iter">
<code class="descname">get_app_iter</code><span class="sig-paren">(</span><em>environ</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.get_app_iter" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the application iterator for the given environ.  Depending
on the request method and the current status code the return value
might be an empty response rather than the one from the response.</p>
<p>If the request method is <cite>HEAD</cite> or the status code is in a range
where the HTTP specification requires an empty response, an empty
iterable is returned.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>environ</strong> – the WSGI environment of the request.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a response iterable.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.get_data">
<code class="descname">get_data</code><span class="sig-paren">(</span><em>as_text=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.get_data" title="Permalink to this definition">¶</a></dt>
<dd><p>The string representation of the response body.  Whenever you call
this property the response iterable is encoded and flattened.  This
can lead to unwanted behavior if you stream big data.</p>
<p>This behavior can be disabled by setting
<a class="reference internal" href="#werkzeug.wrappers.BaseResponse.implicit_sequence_conversion" title="werkzeug.wrappers.BaseResponse.implicit_sequence_conversion"><code class="xref py py-attr docutils literal notranslate"><span class="pre">implicit_sequence_conversion</span></code></a> to <cite>False</cite>.</p>
<p>If <cite>as_text</cite> is set to <cite>True</cite> the return value will be a decoded
unicode string.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.get_wsgi_headers">
<code class="descname">get_wsgi_headers</code><span class="sig-paren">(</span><em>environ</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.get_wsgi_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>This is automatically called right before the response is started
and returns headers modified for the given environment.  It returns a
copy of the headers from the response with some modifications applied
if necessary.</p>
<p>For example the location header (if present) is joined with the root
URL of the environment.  Also the content length is automatically set
to zero here for certain status codes.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.6: </span>Previously that function was called <cite>fix_headers</cite> and modified
the response object in place.  Also since 0.6, IRIs in location
and content-location headers are handled properly.</p>
<p>Also starting with 0.6, Werkzeug will attempt to set the content
length if it is able to figure it out on its own.  This is the
case if all the strings in the response iterable are already
encoded and the iterable is buffered.</p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>environ</strong> – the WSGI environment of the request.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">returns a new <a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a>
object.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.get_wsgi_response">
<code class="descname">get_wsgi_response</code><span class="sig-paren">(</span><em>environ</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.get_wsgi_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the final WSGI response as tuple.  The first item in
the tuple is the application iterator, the second the status and
the third the list of headers.  The response returned is created
specially for the given environment.  For example if the request
method in the WSGI environment is <code class="docutils literal notranslate"><span class="pre">'HEAD'</span></code> the response will
be empty and only the headers and status code will be present.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>environ</strong> – the WSGI environment of the request.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">an <code class="docutils literal notranslate"><span class="pre">(app_iter,</span> <span class="pre">status,</span> <span class="pre">headers)</span></code> tuple.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.implicit_sequence_conversion">
<code class="descname">implicit_sequence_conversion</code><em class="property"> = True</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.implicit_sequence_conversion" title="Permalink to this definition">¶</a></dt>
<dd><p>if set to <cite>False</cite> accessing properties on the response object will
not try to consume the response iterator and convert it into a list.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.2: </span>That attribute was previously called <cite>implicit_seqence_conversion</cite>.
(Notice the typo).  If you did use this feature, you have to adapt
your code to the name change.</p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.is_sequence">
<code class="descname">is_sequence</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.is_sequence" title="Permalink to this definition">¶</a></dt>
<dd><p>If the iterator is buffered, this property will be <cite>True</cite>.  A
response object will consider an iterator to be buffered if the
response attribute is a list or tuple.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.is_streamed">
<code class="descname">is_streamed</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.is_streamed" title="Permalink to this definition">¶</a></dt>
<dd><p>If the response is streamed (the response is not an iterable with
a length information) this property is <cite>True</cite>.  In this case streamed
means that there is no information about the number of iterations.
This is usually <cite>True</cite> if a generator is passed to the response object.</p>
<p>This is useful for checking before applying some sort of post
filtering that should not take place for streamed responses.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.iter_encoded">
<code class="descname">iter_encoded</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.iter_encoded" title="Permalink to this definition">¶</a></dt>
<dd><p>Iter the response encoded with the encoding of the response.
If the response object is invoked as WSGI application the return
value of this method is used as application iterator unless
<a class="reference internal" href="#werkzeug.wrappers.BaseResponse.direct_passthrough" title="werkzeug.wrappers.BaseResponse.direct_passthrough"><code class="xref py py-attr docutils literal notranslate"><span class="pre">direct_passthrough</span></code></a> was activated.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.make_sequence">
<code class="descname">make_sequence</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.make_sequence" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts the response iterator in a list.  By default this happens
automatically if required.  If <cite>implicit_sequence_conversion</cite> is
disabled, this method is not automatically called and some properties
might raise exceptions.  This also encodes all the items.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.max_cookie_size">
<code class="descname">max_cookie_size</code><em class="property"> = 4093</em><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.max_cookie_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Warn if a cookie header exceeds this size. The default, 4093, should be
safely <a class="reference external" href="http://browsercookielimits.squawky.net/">supported by most browsers</a>. A cookie larger than
this size will still be sent, but it may be ignored or handled
incorrectly by some browsers. Set to 0 to disable this check.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.13.</span></p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.set_cookie">
<code class="descname">set_cookie</code><span class="sig-paren">(</span><em>key</em>, <em>value=''</em>, <em>max_age=None</em>, <em>expires=None</em>, <em>path='/'</em>, <em>domain=None</em>, <em>secure=False</em>, <em>httponly=False</em>, <em>samesite=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.set_cookie" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets a cookie. The parameters are the same as in the cookie <cite>Morsel</cite>
object in the Python standard library but it accepts unicode data, too.</p>
<p>A warning is raised if the size of the cookie header exceeds
<a class="reference internal" href="#werkzeug.wrappers.BaseResponse.max_cookie_size" title="werkzeug.wrappers.BaseResponse.max_cookie_size"><code class="xref py py-attr docutils literal notranslate"><span class="pre">max_cookie_size</span></code></a>, but the header will still be set.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – the key (name) of the cookie to be set.</li>
<li><strong>value</strong> – the value of the cookie.</li>
<li><strong>max_age</strong> – should be a number of seconds, or <cite>None</cite> (default) if
the cookie should last only as long as the client’s
browser session.</li>
<li><strong>expires</strong> – should be a <cite>datetime</cite> object or UNIX timestamp.</li>
<li><strong>path</strong> – limits the cookie to a given path, per default it will
span the whole domain.</li>
<li><strong>domain</strong> – if you want to set a cross-domain cookie.  For example,
<code class="docutils literal notranslate"><span class="pre">domain=&quot;.example.com&quot;</span></code> will set a cookie that is
readable by the domain <code class="docutils literal notranslate"><span class="pre">www.example.com</span></code>,
<code class="docutils literal notranslate"><span class="pre">foo.example.com</span></code> etc.  Otherwise, a cookie will only
be readable by the domain that set it.</li>
<li><strong>secure</strong> – If <cite>True</cite>, the cookie will only be available via HTTPS</li>
<li><strong>httponly</strong> – disallow JavaScript to access the cookie.  This is an
extension to the cookie standard and probably not
supported by all browsers.</li>
<li><strong>samesite</strong> – Limits the scope of the cookie such that it will only
be attached to requests if those requests are
“same-site”.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.BaseResponse.set_data">
<code class="descname">set_data</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.set_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets a new string as response.  The value set must be either a
unicode or bytestring.  If a unicode string is set it’s encoded
automatically to the charset of the response (utf-8 by default).</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.BaseResponse.status">
<code class="descname">status</code><a class="headerlink" href="#werkzeug.wrappers.BaseResponse.status" title="Permalink to this definition">¶</a></dt>
<dd><p>The HTTP status code as a string.</p>
</dd></dl>

<dl class="attribute">
<dt>
<code class="descname">status_code</code></dt>
<dd><p>The HTTP status code as a number.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="mixin-classes">
<h2>Mixin Classes<a class="headerlink" href="#mixin-classes" title="Permalink to this headline">¶</a></h2>
<p>Werkzeug also provides helper mixins for various HTTP related functionality
such as etags, cache control, user agents etc.  When subclassing you can
mix those classes in to extend the functionality of the <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseRequest</span></code></a>
or <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseResponse</span></code></a> object.  Here a small example for a request object
that parses accept headers:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="k">import</span> <span class="n">AcceptMixin</span><span class="p">,</span> <span class="n">BaseRequest</span>

<span class="k">class</span> <span class="nc">Request</span><span class="p">(</span><span class="n">BaseRequest</span><span class="p">,</span> <span class="n">AcceptMixin</span><span class="p">):</span>
    <span class="k">pass</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">Request</span></code></a> and <a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal notranslate"><span class="pre">Response</span></code></a> classes subclass the <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseRequest</span></code></a>
and <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseResponse</span></code></a> classes and implement all the mixins Werkzeug provides:</p>
<dl class="class">
<dt id="werkzeug.wrappers.Request">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">Request</code><span class="sig-paren">(</span><em>environ</em>, <em>populate_request=True</em>, <em>shallow=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.Request" title="Permalink to this definition">¶</a></dt>
<dd><p>Full featured request object implementing the following mixins:</p>
<ul class="simple">
<li><a class="reference internal" href="#werkzeug.wrappers.AcceptMixin" title="werkzeug.wrappers.AcceptMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">AcceptMixin</span></code></a> for accept header parsing</li>
<li><a class="reference internal" href="#werkzeug.wrappers.ETagRequestMixin" title="werkzeug.wrappers.ETagRequestMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">ETagRequestMixin</span></code></a> for etag and cache control handling</li>
<li><a class="reference internal" href="#werkzeug.wrappers.UserAgentMixin" title="werkzeug.wrappers.UserAgentMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">UserAgentMixin</span></code></a> for user agent introspection</li>
<li><a class="reference internal" href="#werkzeug.wrappers.AuthorizationMixin" title="werkzeug.wrappers.AuthorizationMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">AuthorizationMixin</span></code></a> for http auth handling</li>
<li><a class="reference internal" href="#werkzeug.wrappers.cors.CORSRequestMixin" title="werkzeug.wrappers.cors.CORSRequestMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">CORSRequestMixin</span></code></a> for Cross
Origin Resource Sharing headers</li>
<li><a class="reference internal" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin" title="werkzeug.wrappers.CommonRequestDescriptorsMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">CommonRequestDescriptorsMixin</span></code></a> for common headers</li>
</ul>
</dd></dl>

<dl class="class">
<dt id="werkzeug.wrappers.Response">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">Response</code><span class="sig-paren">(</span><em>response=None</em>, <em>status=None</em>, <em>headers=None</em>, <em>mimetype=None</em>, <em>content_type=None</em>, <em>direct_passthrough=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.Response" title="Permalink to this definition">¶</a></dt>
<dd><p>Full featured response object implementing the following mixins:</p>
<ul class="simple">
<li><a class="reference internal" href="#werkzeug.wrappers.ETagResponseMixin" title="werkzeug.wrappers.ETagResponseMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">ETagResponseMixin</span></code></a> for etag and cache control handling</li>
<li><a class="reference internal" href="#werkzeug.wrappers.WWWAuthenticateMixin" title="werkzeug.wrappers.WWWAuthenticateMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">WWWAuthenticateMixin</span></code></a> for HTTP authentication support</li>
<li><a class="reference internal" href="#werkzeug.wrappers.cors.CORSResponseMixin" title="werkzeug.wrappers.cors.CORSResponseMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">CORSResponseMixin</span></code></a> for Cross
Origin Resource Sharing headers</li>
<li><a class="reference internal" href="#werkzeug.wrappers.ResponseStreamMixin" title="werkzeug.wrappers.ResponseStreamMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">ResponseStreamMixin</span></code></a> to add support for the <code class="docutils literal notranslate"><span class="pre">stream</span></code>
property</li>
<li><a class="reference internal" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin" title="werkzeug.wrappers.CommonResponseDescriptorsMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">CommonResponseDescriptorsMixin</span></code></a> for various HTTP
descriptors</li>
</ul>
</dd></dl>

<div class="section" id="common-descriptors">
<h3>Common Descriptors<a class="headerlink" href="#common-descriptors" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">CommonRequestDescriptorsMixin</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>A mixin for <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseRequest</span></code></a> subclasses.  Request objects that
mix this class in will automatically get descriptors for a couple of
HTTP headers with automatic type conversion.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_encoding">
<code class="descname">content_encoding</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_encoding" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Encoding entity-header field is used as a
modifier to the media-type. When present, its value indicates
what additional content codings have been applied to the
entity-body, and thus what decoding mechanisms must be applied
in order to obtain the media-type referenced by the Content-Type
header field.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_length">
<code class="descname">content_length</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Length entity-header field indicates the size of the
entity-body in bytes or, in the case of the HEAD method, the size of
the entity-body that would have been sent had the request been a
GET.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_md5">
<code class="descname">content_md5</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_md5" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-MD5 entity-header field, as defined in
RFC 1864, is an MD5 digest of the entity-body for the purpose of
providing an end-to-end message integrity check (MIC) of the
entity-body. (Note: a MIC is good for detecting accidental
modification of the entity-body in transit, but is not proof
against malicious attacks.)</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_type">
<code class="descname">content_type</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Type entity-header field indicates the media
type of the entity-body sent to the recipient or, in the case of
the HEAD method, the media type that would have been sent had
the request been a GET.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.date">
<code class="descname">date</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.date" title="Permalink to this definition">¶</a></dt>
<dd><p>The Date general-header field represents the date and
time at which the message was originated, having the same
semantics as orig-date in RFC 822.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.max_forwards">
<code class="descname">max_forwards</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.max_forwards" title="Permalink to this definition">¶</a></dt>
<dd><p>The Max-Forwards request-header field provides a
mechanism with the TRACE and OPTIONS methods to limit the number
of proxies or gateways that can forward the request to the next
inbound server.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.mimetype">
<code class="descname">mimetype</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.mimetype" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.content_type" title="werkzeug.wrappers.CommonRequestDescriptorsMixin.content_type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">content_type</span></code></a>, but without parameters (eg, without
charset, type etc.) and always lowercase.  For example if the content
type is <code class="docutils literal notranslate"><span class="pre">text/HTML;</span> <span class="pre">charset=utf-8</span></code> the mimetype would be
<code class="docutils literal notranslate"><span class="pre">'text/html'</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.mimetype_params">
<code class="descname">mimetype_params</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.mimetype_params" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype parameters as dict.  For example if the content
type is <code class="docutils literal notranslate"><span class="pre">text/html;</span> <span class="pre">charset=utf-8</span></code> the params would be
<code class="docutils literal notranslate"><span class="pre">{'charset':</span> <span class="pre">'utf-8'}</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.pragma">
<code class="descname">pragma</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.pragma" title="Permalink to this definition">¶</a></dt>
<dd><p>The Pragma general-header field is used to include
implementation-specific directives that might apply to any recipient
along the request/response chain.  All pragma directives specify
optional behavior from the viewpoint of the protocol; however, some
systems MAY require that behavior be consistent with the directives.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonRequestDescriptorsMixin.referrer">
<code class="descname">referrer</code><a class="headerlink" href="#werkzeug.wrappers.CommonRequestDescriptorsMixin.referrer" title="Permalink to this definition">¶</a></dt>
<dd><p>The Referer[sic] request-header field allows the client
to specify, for the server’s benefit, the address (URI) of the
resource from which the Request-URI was obtained (the
“referrer”, although the header field is misspelled).</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">CommonResponseDescriptorsMixin</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>A mixin for <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseResponse</span></code></a> subclasses.  Response objects that
mix this class in will automatically get descriptors for a couple of
HTTP headers with automatic type conversion.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.age">
<code class="descname">age</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.age" title="Permalink to this definition">¶</a></dt>
<dd><p>The Age response-header field conveys the sender’s
estimate of the amount of time since the response (or its
revalidation) was generated at the origin server.</p>
<p>Age values are non-negative decimal integers, representing time
in seconds.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.allow">
<code class="descname">allow</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.allow" title="Permalink to this definition">¶</a></dt>
<dd><p>The Allow entity-header field lists the set of methods
supported by the resource identified by the Request-URI. The
purpose of this field is strictly to inform the recipient of
valid methods associated with the resource. An Allow header
field MUST be present in a 405 (Method Not Allowed)
response.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_encoding">
<code class="descname">content_encoding</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_encoding" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Encoding entity-header field is used as a
modifier to the media-type. When present, its value indicates
what additional content codings have been applied to the
entity-body, and thus what decoding mechanisms must be applied
in order to obtain the media-type referenced by the Content-Type
header field.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_language">
<code class="descname">content_language</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_language" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Language entity-header field describes the
natural language(s) of the intended audience for the enclosed
entity. Note that this might not be equivalent to all the
languages used within the entity-body.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_length">
<code class="descname">content_length</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Length entity-header field indicates the size
of the entity-body, in decimal number of OCTETs, sent to the
recipient or, in the case of the HEAD method, the size of the
entity-body that would have been sent had the request been a
GET.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_location">
<code class="descname">content_location</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_location" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Location entity-header field MAY be used to
supply the resource location for the entity enclosed in the
message when that entity is accessible from a location separate
from the requested resource’s URI.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_md5">
<code class="descname">content_md5</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_md5" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-MD5 entity-header field, as defined in
RFC 1864, is an MD5 digest of the entity-body for the purpose of
providing an end-to-end message integrity check (MIC) of the
entity-body. (Note: a MIC is good for detecting accidental
modification of the entity-body in transit, but is not proof
against malicious attacks.)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_security_policy">
<code class="descname">content_security_policy</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_security_policy" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Security-Policy header adds an additional layer of
security to help detect and mitigate certain types of attacks.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_security_policy_report_only">
<code class="descname">content_security_policy_report_only</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_security_policy_report_only" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Security-Policy-Report-Only header adds a csp policy
that is not enforced but is reported thereby helping detect
certain types of attacks.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.content_type">
<code class="descname">content_type</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>The Content-Type entity-header field indicates the media
type of the entity-body sent to the recipient or, in the case of
the HEAD method, the media type that would have been sent had
the request been a GET.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.date">
<code class="descname">date</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.date" title="Permalink to this definition">¶</a></dt>
<dd><p>The Date general-header field represents the date and
time at which the message was originated, having the same
semantics as orig-date in RFC 822.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.expires">
<code class="descname">expires</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.expires" title="Permalink to this definition">¶</a></dt>
<dd><p>The Expires entity-header field gives the date/time after
which the response is considered stale. A stale cache entry may
not normally be returned by a cache.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.last_modified">
<code class="descname">last_modified</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.last_modified" title="Permalink to this definition">¶</a></dt>
<dd><p>The Last-Modified entity-header field indicates the date
and time at which the origin server believes the variant was
last modified.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.location">
<code class="descname">location</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.location" title="Permalink to this definition">¶</a></dt>
<dd><p>The Location response-header field is used to redirect
the recipient to a location other than the Request-URI for
completion of the request or identification of a new
resource.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.mimetype">
<code class="descname">mimetype</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.mimetype" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype (content type without charset etc.)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.mimetype_params">
<code class="descname">mimetype_params</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.mimetype_params" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype parameters as dict. For example if the
content type is <code class="docutils literal notranslate"><span class="pre">text/html;</span> <span class="pre">charset=utf-8</span></code> the params would be
<code class="docutils literal notranslate"><span class="pre">{'charset':</span> <span class="pre">'utf-8'}</span></code>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.retry_after">
<code class="descname">retry_after</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.retry_after" title="Permalink to this definition">¶</a></dt>
<dd><p>The Retry-After response-header field can be used with a
503 (Service Unavailable) response to indicate how long the
service is expected to be unavailable to the requesting client.</p>
<p>Time in seconds until expiration or date.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.CommonResponseDescriptorsMixin.vary">
<code class="descname">vary</code><a class="headerlink" href="#werkzeug.wrappers.CommonResponseDescriptorsMixin.vary" title="Permalink to this definition">¶</a></dt>
<dd><p>The Vary field value indicates the set of request-header
fields that fully determines, while the response is fresh,
whether a cache is permitted to use the response to reply to a
subsequent request without revalidation.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="response-stream">
<h3>Response Stream<a class="headerlink" href="#response-stream" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="werkzeug.wrappers.ResponseStreamMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">ResponseStreamMixin</code><a class="headerlink" href="#werkzeug.wrappers.ResponseStreamMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Mixin for <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseResponse</span></code></a> subclasses.  Classes that inherit from
this mixin will automatically get a <a class="reference internal" href="#werkzeug.wrappers.ResponseStreamMixin.stream" title="werkzeug.wrappers.ResponseStreamMixin.stream"><code class="xref py py-attr docutils literal notranslate"><span class="pre">stream</span></code></a> property that provides
a write-only interface to the response iterable.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.ResponseStreamMixin.stream">
<code class="descname">stream</code><a class="headerlink" href="#werkzeug.wrappers.ResponseStreamMixin.stream" title="Permalink to this definition">¶</a></dt>
<dd><p>The response iterable as write-only stream.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="accept">
<h3>Accept<a class="headerlink" href="#accept" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="werkzeug.wrappers.AcceptMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">AcceptMixin</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>A mixin for classes with an <code class="xref py py-attr docutils literal notranslate"><span class="pre">environ</span></code> attribute
to get all the HTTP accept headers as
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal notranslate"><span class="pre">Accept</span></code></a> objects (or subclasses
thereof).</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.AcceptMixin.accept_charsets">
<code class="descname">accept_charsets</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin.accept_charsets" title="Permalink to this definition">¶</a></dt>
<dd><p>List of charsets this client supports as
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.CharsetAccept" title="werkzeug.datastructures.CharsetAccept"><code class="xref py py-class docutils literal notranslate"><span class="pre">CharsetAccept</span></code></a> object.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.AcceptMixin.accept_encodings">
<code class="descname">accept_encodings</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin.accept_encodings" title="Permalink to this definition">¶</a></dt>
<dd><p>List of encodings this client accepts.  Encodings in a HTTP term
are compression encodings such as gzip.  For charsets have a look at
<code class="xref py py-attr docutils literal notranslate"><span class="pre">accept_charset</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.AcceptMixin.accept_languages">
<code class="descname">accept_languages</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin.accept_languages" title="Permalink to this definition">¶</a></dt>
<dd><p>List of languages this client accepts as
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.LanguageAccept" title="werkzeug.datastructures.LanguageAccept"><code class="xref py py-class docutils literal notranslate"><span class="pre">LanguageAccept</span></code></a> object.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.AcceptMixin.accept_mimetypes">
<code class="descname">accept_mimetypes</code><a class="headerlink" href="#werkzeug.wrappers.AcceptMixin.accept_mimetypes" title="Permalink to this definition">¶</a></dt>
<dd><p>List of mimetypes this client supports as
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.MIMEAccept" title="werkzeug.datastructures.MIMEAccept"><code class="xref py py-class docutils literal notranslate"><span class="pre">MIMEAccept</span></code></a> object.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="authentication">
<h3>Authentication<a class="headerlink" href="#authentication" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="werkzeug.wrappers.AuthorizationMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">AuthorizationMixin</code><a class="headerlink" href="#werkzeug.wrappers.AuthorizationMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds an <a class="reference internal" href="#werkzeug.wrappers.AuthorizationMixin.authorization" title="werkzeug.wrappers.AuthorizationMixin.authorization"><code class="xref py py-attr docutils literal notranslate"><span class="pre">authorization</span></code></a> property that represents the parsed
value of the <cite>Authorization</cite> header as
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.Authorization" title="werkzeug.datastructures.Authorization"><code class="xref py py-class docutils literal notranslate"><span class="pre">Authorization</span></code></a> object.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.AuthorizationMixin.authorization">
<code class="descname">authorization</code><a class="headerlink" href="#werkzeug.wrappers.AuthorizationMixin.authorization" title="Permalink to this definition">¶</a></dt>
<dd><p>The <cite>Authorization</cite> object in parsed form.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.wrappers.WWWAuthenticateMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">WWWAuthenticateMixin</code><a class="headerlink" href="#werkzeug.wrappers.WWWAuthenticateMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a <a class="reference internal" href="#werkzeug.wrappers.WWWAuthenticateMixin.www_authenticate" title="werkzeug.wrappers.WWWAuthenticateMixin.www_authenticate"><code class="xref py py-attr docutils literal notranslate"><span class="pre">www_authenticate</span></code></a> property to a response object.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.WWWAuthenticateMixin.www_authenticate">
<code class="descname">www_authenticate</code><a class="headerlink" href="#werkzeug.wrappers.WWWAuthenticateMixin.www_authenticate" title="Permalink to this definition">¶</a></dt>
<dd><p>The <cite>WWW-Authenticate</cite> header in a parsed form.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="cors">
<h3>CORS<a class="headerlink" href="#cors" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="werkzeug.wrappers.cors.CORSRequestMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.cors.</code><code class="descname">CORSRequestMixin</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSRequestMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>A mixin for <a class="reference internal" href="#werkzeug.wrappers.BaseRequest" title="werkzeug.wrappers.BaseRequest"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseRequest</span></code></a> subclasses
that adds descriptors for Cross Origin Resource Sharing (CORS)
headers.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.0.</span></p>
</div>
<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSRequestMixin.access_control_request_headers">
<code class="descname">access_control_request_headers</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSRequestMixin.access_control_request_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Sent with a preflight request to indicate which headers will be sent with the cross origin request. Set <a class="reference internal" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_headers" title="werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_headers"><code class="xref py py-attr docutils literal notranslate"><span class="pre">access_control_allow_headers</span></code></a> on the response to indicate which headers are allowed.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSRequestMixin.access_control_request_method">
<code class="descname">access_control_request_method</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSRequestMixin.access_control_request_method" title="Permalink to this definition">¶</a></dt>
<dd><p>Sent with a preflight request to indicate which method will be used for the cross origin request. Set <a class="reference internal" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_methods" title="werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_methods"><code class="xref py py-attr docutils literal notranslate"><span class="pre">access_control_allow_methods</span></code></a> on the response to indicate which methods are allowed.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSRequestMixin.origin">
<code class="descname">origin</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSRequestMixin.origin" title="Permalink to this definition">¶</a></dt>
<dd><p>The host that the request originated from. Set <a class="reference internal" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_origin" title="werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_origin"><code class="xref py py-attr docutils literal notranslate"><span class="pre">access_control_allow_origin</span></code></a> on the response to indicate which origins are allowed.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.wrappers.cors.CORSResponseMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.cors.</code><code class="descname">CORSResponseMixin</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSResponseMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>A mixin for <a class="reference internal" href="#werkzeug.wrappers.BaseResponse" title="werkzeug.wrappers.BaseResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseResponse</span></code></a> subclasses
that adds descriptors for Cross Origin Resource Sharing (CORS)
headers.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.0.</span></p>
</div>
<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_credentials">
<code class="descname">access_control_allow_credentials</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_credentials" title="Permalink to this definition">¶</a></dt>
<dd><p>Whether credentials can be shared by the browser to
JavaScript code. As part of the preflight request it indicates
whether credentials can be used on the cross origin request.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_headers">
<code class="descname">access_control_allow_headers</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Which headers can be sent with the cross origin request.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_methods">
<code class="descname">access_control_allow_methods</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_methods" title="Permalink to this definition">¶</a></dt>
<dd><p>Which methods can be used for the cross origin request.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_origin">
<code class="descname">access_control_allow_origin</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_allow_origin" title="Permalink to this definition">¶</a></dt>
<dd><p>The origin or ‘*’ for any origin that may make cross origin requests.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSResponseMixin.access_control_expose_headers">
<code class="descname">access_control_expose_headers</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_expose_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Which headers can be shared by the browser to JavaScript code.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.cors.CORSResponseMixin.access_control_max_age">
<code class="descname">access_control_max_age</code><a class="headerlink" href="#werkzeug.wrappers.cors.CORSResponseMixin.access_control_max_age" title="Permalink to this definition">¶</a></dt>
<dd><p>The maximum age in seconds the access control settings can be cached for.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="etag">
<h3>ETag<a class="headerlink" href="#etag" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="werkzeug.wrappers.ETagRequestMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">ETagRequestMixin</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Add entity tag and cache descriptors to a request object or object with
a WSGI environment available as <a class="reference internal" href="#werkzeug.wrappers.BaseRequest.environ" title="werkzeug.wrappers.BaseRequest.environ"><code class="xref py py-attr docutils literal notranslate"><span class="pre">environ</span></code></a>.  This not
only provides access to etags but also to the cache control header.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.cache_control">
<code class="descname">cache_control</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.cache_control" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.RequestCacheControl" title="werkzeug.datastructures.RequestCacheControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">RequestCacheControl</span></code></a> object
for the incoming cache control headers.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_match">
<code class="descname">if_match</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_match" title="Permalink to this definition">¶</a></dt>
<dd><p>An object containing all the etags in the <cite>If-Match</cite> header.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.ETags" title="werkzeug.datastructures.ETags"><code class="xref py py-class docutils literal notranslate"><span class="pre">ETags</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_modified_since">
<code class="descname">if_modified_since</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_modified_since" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed <cite>If-Modified-Since</cite> header as datetime object.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_none_match">
<code class="descname">if_none_match</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_none_match" title="Permalink to this definition">¶</a></dt>
<dd><p>An object containing all the etags in the <cite>If-None-Match</cite> header.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.ETags" title="werkzeug.datastructures.ETags"><code class="xref py py-class docutils literal notranslate"><span class="pre">ETags</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_range">
<code class="descname">if_range</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_range" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed <cite>If-Range</cite> header.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.IfRange" title="werkzeug.datastructures.IfRange"><code class="xref py py-class docutils literal notranslate"><span class="pre">IfRange</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.if_unmodified_since">
<code class="descname">if_unmodified_since</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.if_unmodified_since" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed <cite>If-Unmodified-Since</cite> header as datetime object.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.ETagRequestMixin.range">
<code class="descname">range</code><a class="headerlink" href="#werkzeug.wrappers.ETagRequestMixin.range" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed <cite>Range</cite> header.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.Range" title="werkzeug.datastructures.Range"><code class="xref py py-class docutils literal notranslate"><span class="pre">Range</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.wrappers.ETagResponseMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">ETagResponseMixin</code><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds extra functionality to a response object for etag and cache
handling.  This mixin requires an object with at least a <cite>headers</cite>
object that implements a dict like interface similar to
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a>.</p>
<p>If you want the <a class="reference internal" href="#werkzeug.wrappers.ETagResponseMixin.freeze" title="werkzeug.wrappers.ETagResponseMixin.freeze"><code class="xref py py-meth docutils literal notranslate"><span class="pre">freeze()</span></code></a> method to automatically add an etag, you
have to mixin this method before the response base class.  The default
response class does not do that.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.ETagResponseMixin.accept_ranges">
<code class="descname">accept_ranges</code><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.accept_ranges" title="Permalink to this definition">¶</a></dt>
<dd><p>The <cite>Accept-Ranges</cite> header. Even though the name would
indicate that multiple values are supported, it must be one
string token only.</p>
<p>The values <code class="docutils literal notranslate"><span class="pre">'bytes'</span></code> and <code class="docutils literal notranslate"><span class="pre">'none'</span></code> are common.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.add_etag">
<code class="descname">add_etag</code><span class="sig-paren">(</span><em>overwrite=False</em>, <em>weak=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.add_etag" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an etag for the current response if there is none yet.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.ETagResponseMixin.cache_control">
<code class="descname">cache_control</code><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.cache_control" title="Permalink to this definition">¶</a></dt>
<dd><p>The Cache-Control general-header field is used to specify
directives that MUST be obeyed by all caching mechanisms along the
request/response chain.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.ETagResponseMixin.content_range">
<code class="descname">content_range</code><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.content_range" title="Permalink to this definition">¶</a></dt>
<dd><p>The <code class="docutils literal notranslate"><span class="pre">Content-Range</span></code> header as a
<a class="reference internal" href="../datastructures/index.html#werkzeug.datastructures.ContentRange" title="werkzeug.datastructures.ContentRange"><code class="xref py py-class docutils literal notranslate"><span class="pre">ContentRange</span></code></a> object. Available
even if the header is not set.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.freeze">
<code class="descname">freeze</code><span class="sig-paren">(</span><em>no_etag=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.freeze" title="Permalink to this definition">¶</a></dt>
<dd><p>Call this method if you want to make your response object ready for
pickeling.  This buffers the generator if there is one.  This also
sets the etag unless <cite>no_etag</cite> is set to <cite>True</cite>.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.get_etag">
<code class="descname">get_etag</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.get_etag" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a tuple in the form <code class="docutils literal notranslate"><span class="pre">(etag,</span> <span class="pre">is_weak)</span></code>.  If there is no
ETag the return value is <code class="docutils literal notranslate"><span class="pre">(None,</span> <span class="pre">None)</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.make_conditional">
<code class="descname">make_conditional</code><span class="sig-paren">(</span><em>request_or_environ</em>, <em>accept_ranges=False</em>, <em>complete_length=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.make_conditional" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the response conditional to the request.  This method works
best if an etag was defined for the response already.  The <cite>add_etag</cite>
method can be used to do that.  If called without etag just the date
header is set.</p>
<p>This does nothing if the request method in the request or environ is
anything but GET or HEAD.</p>
<p>For optimal performance when handling range requests, it’s recommended
that your response data object implements <cite>seekable</cite>, <cite>seek</cite> and <cite>tell</cite>
methods as described by <a class="reference external" href="https://docs.python.org/3/library/io.html#io.IOBase" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.IOBase</span></code></a>.  Objects returned by
<a class="reference internal" href="../wsgi/index.html#werkzeug.wsgi.wrap_file" title="werkzeug.wsgi.wrap_file"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wrap_file()</span></code></a> automatically implement those methods.</p>
<p>It does not remove the body of the response because that’s something
the <code class="xref py py-meth docutils literal notranslate"><span class="pre">__call__()</span></code> function does for us automatically.</p>
<p>Returns self so that you can do <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">resp.make_conditional(req)</span></code>
but modifies the object in-place.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>request_or_environ</strong> – a request object or WSGI environment to be
used to make the response conditional
against.</li>
<li><strong>accept_ranges</strong> – This parameter dictates the value of
<cite>Accept-Ranges</cite> header. If <code class="docutils literal notranslate"><span class="pre">False</span></code> (default),
the header is not set. If <code class="docutils literal notranslate"><span class="pre">True</span></code>, it will be set
to <code class="docutils literal notranslate"><span class="pre">&quot;bytes&quot;</span></code>. If <code class="docutils literal notranslate"><span class="pre">None</span></code>, it will be set to
<code class="docutils literal notranslate"><span class="pre">&quot;none&quot;</span></code>. If it’s a string, it will use this
value.</li>
<li><strong>complete_length</strong> – Will be used only in valid Range Requests.
It will set <cite>Content-Range</cite> complete length
value and compute <cite>Content-Length</cite> real value.
This parameter is mandatory for successful
Range Requests completion.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><a class="reference internal" href="../exceptions/index.html#werkzeug.exceptions.RequestedRangeNotSatisfiable" title="werkzeug.exceptions.RequestedRangeNotSatisfiable"><code class="xref py py-class docutils literal notranslate"><span class="pre">RequestedRangeNotSatisfiable</span></code></a>
if <cite>Range</cite> header could not be parsed or satisfied.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.ETagResponseMixin.set_etag">
<code class="descname">set_etag</code><span class="sig-paren">(</span><em>etag</em>, <em>weak=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.ETagResponseMixin.set_etag" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the etag, and override the old one if there was one.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="user-agent">
<h3>User Agent<a class="headerlink" href="#user-agent" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="werkzeug.wrappers.UserAgentMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.</code><code class="descname">UserAgentMixin</code><a class="headerlink" href="#werkzeug.wrappers.UserAgentMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a <cite>user_agent</cite> attribute to the request object which
contains the parsed user agent of the browser that triggered the
request as a <a class="reference internal" href="../utils/index.html#werkzeug.useragents.UserAgent" title="werkzeug.useragents.UserAgent"><code class="xref py py-class docutils literal notranslate"><span class="pre">UserAgent</span></code></a> object.</p>
<dl class="attribute">
<dt id="werkzeug.wrappers.UserAgentMixin.user_agent">
<code class="descname">user_agent</code><a class="headerlink" href="#werkzeug.wrappers.UserAgentMixin.user_agent" title="Permalink to this definition">¶</a></dt>
<dd><p>The current user agent.</p>
</dd></dl>

</dd></dl>

</div>
</div>
<div class="section" id="extra-mixin-classes">
<h2>Extra Mixin Classes<a class="headerlink" href="#extra-mixin-classes" title="Permalink to this headline">¶</a></h2>
<p>These mixins are not included in the default <a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">Request</span></code></a> and
<a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal notranslate"><span class="pre">Response</span></code></a> classes. They provide extra behavior that needs to be
opted into by creating your own subclasses:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Response</span><span class="p">(</span><span class="n">JSONMixin</span><span class="p">,</span> <span class="n">BaseResponse</span><span class="p">):</span>
    <span class="k">pass</span>
</pre></div>
</div>
<div class="section" id="json">
<h3>JSON<a class="headerlink" href="#json" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="werkzeug.wrappers.json.JSONMixin">
<em class="property">class </em><code class="descclassname">werkzeug.wrappers.json.</code><code class="descname">JSONMixin</code><a class="headerlink" href="#werkzeug.wrappers.json.JSONMixin" title="Permalink to this definition">¶</a></dt>
<dd><p>Mixin to parse <code class="xref py py-attr docutils literal notranslate"><span class="pre">data</span></code> as JSON. Can be mixed in for both
<a class="reference internal" href="#werkzeug.wrappers.Request" title="werkzeug.wrappers.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">Request</span></code></a> and
<a class="reference internal" href="#werkzeug.wrappers.Response" title="werkzeug.wrappers.Response"><code class="xref py py-class docutils literal notranslate"><span class="pre">Response</span></code></a> classes.</p>
<p>If <a class="reference external" href="https://simplejson.readthedocs.io/en/latest/">simplejson</a> is installed it is preferred over Python’s built-in
<a class="reference external" href="https://docs.python.org/3/library/json.html#module-json" title="(in Python v3.8)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">json</span></code></a> module.</p>
<dl class="method">
<dt id="werkzeug.wrappers.json.JSONMixin.get_json">
<code class="descname">get_json</code><span class="sig-paren">(</span><em>force=False</em>, <em>silent=False</em>, <em>cache=True</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.json.JSONMixin.get_json" title="Permalink to this definition">¶</a></dt>
<dd><p>Parse <code class="xref py py-attr docutils literal notranslate"><span class="pre">data</span></code> as JSON.</p>
<p>If the mimetype does not indicate JSON
(<em class="mimetype">application/json</em>, see <a class="reference internal" href="#werkzeug.wrappers.json.JSONMixin.is_json" title="werkzeug.wrappers.json.JSONMixin.is_json"><code class="xref py py-meth docutils literal notranslate"><span class="pre">is_json()</span></code></a>), this
returns <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
<p>If parsing fails, <a class="reference internal" href="#werkzeug.wrappers.json.JSONMixin.on_json_loading_failed" title="werkzeug.wrappers.json.JSONMixin.on_json_loading_failed"><code class="xref py py-meth docutils literal notranslate"><span class="pre">on_json_loading_failed()</span></code></a> is called and
its return value is used as the return value.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>force</strong> – Ignore the mimetype and always try to parse JSON.</li>
<li><strong>silent</strong> – Silence parsing errors and return <code class="docutils literal notranslate"><span class="pre">None</span></code>
instead.</li>
<li><strong>cache</strong> – Store the parsed JSON to return for subsequent
calls.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.json.JSONMixin.is_json">
<code class="descname">is_json</code><a class="headerlink" href="#werkzeug.wrappers.json.JSONMixin.is_json" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the mimetype indicates JSON data, either
<em class="mimetype">application/json</em> or <em class="mimetype">application/*+json</em>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.json.JSONMixin.json">
<code class="descname">json</code><a class="headerlink" href="#werkzeug.wrappers.json.JSONMixin.json" title="Permalink to this definition">¶</a></dt>
<dd><p>The parsed JSON data if <code class="xref py py-attr docutils literal notranslate"><span class="pre">mimetype</span></code> indicates JSON
(<em class="mimetype">application/json</em>, see <a class="reference internal" href="#werkzeug.wrappers.json.JSONMixin.is_json" title="werkzeug.wrappers.json.JSONMixin.is_json"><code class="xref py py-meth docutils literal notranslate"><span class="pre">is_json()</span></code></a>).</p>
<p>Calls <a class="reference internal" href="#werkzeug.wrappers.json.JSONMixin.get_json" title="werkzeug.wrappers.json.JSONMixin.get_json"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_json()</span></code></a> with default arguments.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.wrappers.json.JSONMixin.json_module">
<code class="descname">json_module</code><a class="headerlink" href="#werkzeug.wrappers.json.JSONMixin.json_module" title="Permalink to this definition">¶</a></dt>
<dd><p>A module or other object that has <code class="docutils literal notranslate"><span class="pre">dumps</span></code> and <code class="docutils literal notranslate"><span class="pre">loads</span></code>
functions that match the API of the built-in <a class="reference external" href="https://docs.python.org/3/library/json.html#module-json" title="(in Python v3.8)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">json</span></code></a> module.</p>
<p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">_JSONModule</span></code></p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.wrappers.json.JSONMixin.on_json_loading_failed">
<code class="descname">on_json_loading_failed</code><span class="sig-paren">(</span><em>e</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.wrappers.json.JSONMixin.on_json_loading_failed" title="Permalink to this definition">¶</a></dt>
<dd><p>Called if <a class="reference internal" href="#werkzeug.wrappers.json.JSONMixin.get_json" title="werkzeug.wrappers.json.JSONMixin.get_json"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_json()</span></code></a> parsing fails and isn’t silenced.
If this method returns a value, it is used as the return value
for <a class="reference internal" href="#werkzeug.wrappers.json.JSONMixin.get_json" title="werkzeug.wrappers.json.JSONMixin.get_json"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_json()</span></code></a>. The default implementation raises
<a class="reference internal" href="../exceptions/index.html#werkzeug.exceptions.BadRequest" title="werkzeug.exceptions.BadRequest"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BadRequest</span></code></a>.</p>
</dd></dl>

</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
  <span id="sidebar-top"></span>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  
    
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/werkzeug.png" alt="Logo"/>
            </a></p>
  

  <h3>Contents</h3>
  <ul>
<li><a class="reference internal" href="#">Request / Response Objects</a><ul>
<li><a class="reference internal" href="#how-they-work">How they Work</a></li>
<li><a class="reference internal" href="#mutability-and-reusability-of-wrappers">Mutability and Reusability of Wrappers</a></li>
<li><a class="reference internal" href="#base-wrappers">Base Wrappers</a></li>
<li><a class="reference internal" href="#mixin-classes">Mixin Classes</a><ul>
<li><a class="reference internal" href="#common-descriptors">Common Descriptors</a></li>
<li><a class="reference internal" href="#response-stream">Response Stream</a></li>
<li><a class="reference internal" href="#accept">Accept</a></li>
<li><a class="reference internal" href="#authentication">Authentication</a></li>
<li><a class="reference internal" href="#cors">CORS</a></li>
<li><a class="reference internal" href="#etag">ETag</a></li>
<li><a class="reference internal" href="#user-agent">User Agent</a></li>
</ul>
</li>
<li><a class="reference internal" href="#extra-mixin-classes">Extra Mixin Classes</a><ul>
<li><a class="reference internal" href="#json">JSON</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h3>Navigation</h3>
<ul>
  <li><a href="../index.html">Overview</a>
    <ul>
          <li>Previous: <a href="../debug/index.html" title="previous chapter">Debugging Applications</a>
          <li>Next: <a href="../routing/index.html" title="next chapter">URL Routing</a>
    </ul>
  </li>
</ul>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://werkzeug.palletsprojects.com/en/1.0.x/search/" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
  
    <div class="footer" role="contentinfo">
        &#169; Copyright 2007 Pallets.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
    </div>
    <script>
      if (typeof READTHEDOCS_DATA !== 'undefined') {
        if (!READTHEDOCS_DATA.features) {
          READTHEDOCS_DATA.features = {};
        }
        READTHEDOCS_DATA.features.docsearch_disabled = true;
      }
    </script>

  </body>

<!-- Mirrored from werkzeug.palletsprojects.com/en/1.0.x/wrappers/ by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 15 Sep 2020 06:37:09 GMT -->
</html>